<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>location地址栏对象</title>
    <style>
        p{
            text-align: center;
        }
        span{
            color: red;
        }
    </style>
</head>
<body>
    <p id = "word">
        注册成功！<span id="time">5</span>秒之后自动跳转到首页...
    </p>
    <script type="text/javascript">
     let times=5;
        setInterval(function(){
            if(times>0 && times<=5){
            let num = document.getElementById("time");
            num.innerHTML=times;
                times--;
            }else{
                location.href="index.html";
            }   
        },1000);

    </script>
</body>
</html>